<template>
	<view style="height: 100%;">
		<view class="centent">
			<view class="navtopbox">
				<view class="navtopboxcenter">
					<scroll-view scroll-y="true" style="height:100% ;">
						<view class="navlist" @tap="toclassggxiangqing(item.id)" v-for="(item,index) in gglist"
							:key="index" v-if="gglist.length>0">
							<view class="title">
								<text>【</text>
								<text>{{item.newsname}}</text>
								<text>】</text>
							</view>
							<view class="jianyao">
								<text>{{item.summary}}</text>
							</view>
							<view class="time">
								<text>{{item.time}}</text>
								<text style="float: right;margin-right: 8rpx;">{{item.author}}</text>
							</view>
							<view class="tojiantou">
								<image src="../../static/jiantou.png" mode=""></image>
							</view>
						</view>
						<kongyemian v-if="gglist.length<1" :isLoding="loding"></kongyemian>
					</scroll-view>

				</view>
			</view>
			<view class="xie" @tap="xiexin">
				<image src="../../static/xie.png" mode=""></image>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutation,
		mapActions
	} from 'vuex';
	export default {
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				isLogin: state => state.user.isLogin
			})
		},
		data() {
			return {
				class_id: 0,
				gglist: [],
				loding: true
			}
		},
		methods: {

			classlistshow() {
				this.loding = true
				this.$store
					.dispatch('classlist', {
						token: this.userInfo.token,
						class_id: this.class_id

					})
					.then(res => {
						this.gglist = res.data.data;
						this.loding = false
					});
			},
			toclassggxiangqing(id) {
				uni.navigateTo({
					url: '../../pages/ggxiangqing/ggxiangqing?id=' + id
				})
			},
			xiexin() {
					
				if(this.isLogin){
					uni.navigateTo({
						url: "../teacherxiexin/teacherxiexin?class_id="+this.class_id
					})
				}else{
					uni.navigateTo({
						url: '../login/login'
					})
				}
				
			},
		},
		onShow() {
			this.classlistshow()
		},
		onLoad(data) {
			this.class_id = data.class_id
			this.classlistshow()
		},
		onPullDownRefresh() {
			this.classlistshow()
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1500)
		}
	}
</script>

<style lang="less">
	page {
		height: 100%;
		background-color: #f4f4f4;
		box-sizing: border-box;

	}

	.centent {
		
		background-image: url(../../static/keding.png);
		background-size: 100% auto;
		background-repeat: no-repeat;
		width: 100%;
		height: 100%;

		.navtopbox {
			width: 100%;
			height: 100%;
			// background-color: #222222;
			padding: 20rpx;
			box-sizing: border-box;

			.navtopboxcenter {
				width: 100%;
				height: 100%;
				background-color: #fff;
				box-shadow: 0rpx 4rpx 17rpx 4rpx rgba(201, 202, 208, 0.35);
				border-radius: 15rpx;
				overflow: hidden;

				.navlist {
					position: relative;
					width: 100%;
					min-height: 200rpx;
					border-bottom: 2rpx solid #ccc;
					padding: 20rpx 40rpx 20rpx 20rpx;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					justify-content: space-evenly;

					.title {
						font-size: 32rpx;
						font-weight: bold;

					}

					.jianyao {
						font-size: 24rpx;

					}


					.time {
						font-size: 24rpx;
						color: #999999;
					}

					.tojiantou {
						position: absolute;
						right: 13rpx;

						image {
							width: 27rpx;
							height: 45rpx;
						}
					}
				}
			}
		}


	}

	.xie {
		position: absolute;
		right: 40rpx;
		top: 0;
		width: 100rpx;
		height: 100rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>
